<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="Content-Language" content="zh-CN"><title>networkctl
  中文手册 [金步国]</title><style>
@font-face { font-family: "JinBuGuoWebMono"; src: url("http://www.jinbuguo.com/d/mono.ttf") format("truetype"); }
* { font-family: "JinBuGuoWebMono", "Ubuntu Mono", "Consolas", "Menlo", monospace; }
body { margin:10px; }
h1 { text-align:center; background:#ddd; }
h2#auth_name { text-align:center; margin: 10px 5%; }

    a.headerlink {
      color: #c60f0f;
      font-size: 0.8em;
      padding: 0 4px 0 4px;
      text-decoration: none;
      visibility: hidden;
    }

    a.headerlink:hover {
      background-color: #c60f0f;
      color: white;
    }

    h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
      visibility: visible;
    }
</style><script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d286c55b63a3c54a1e43d10d4c203e75"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><h1>networkctl 中文手册</h1><h2 id="auth_name">译者：<strong><a href="../index.html">金步国</a></strong></h2><hr><h3>版权声明</h3><p>本文译者是一位开源理念的坚定支持者，所以本文虽然不是软件，但是遵照开源的精神发布。</p><ul><li>无担保：本文译者不保证译文内容准确无误，亦不承担任何由于使用此文档所导致的损失。</li><li>自由使用：任何人都可以自由的<u>阅读/链接/打印</u>此文档，无需任何附加条件。</li><li>名誉权：任何人都可以自由的<u>转载/引用/再创作</u>此文档，但必须保留译者署名并注明出处。</li></ul><h3>其他作品</h3><p>本文译者十分愿意与他人分享劳动成果，如果你对我的其他翻译作品或者技术文章有兴趣，可以在如下位置查看现有的作品集：</p><ul><li><a href="../index.html">金步国作品集</a> [ <a href="../index.html">http://www.jinbuguo.com/</a> ]</li></ul><h3>联系方式</h3><p>由于译者水平有限，因此不能保证译文内容准确无误。如果你发现了译文中的错误(哪怕是错别字也好)，请来信指出，任何提高译文质量的建议我都将虚心接纳。</p><ul><li>Email(QQ)：70171448在QQ邮箱</li></ul><hr><a href="systemd.index.html">手册索引</a> ·
  <a href="systemd.directives.html">指令索引</a><span style="float:right">systemd-241</span><hr><div class="refentry"><a name="networkctl"></a><div class="titlepage"></div><div class="refnamediv"><h2>名称</h2><p>networkctl — 查询网络连接的状态</p></div><div class="refsynopsisdiv"><h2>大纲</h2><div class="cmdsynopsis"><p><code class="command">networkctl</code>  [OPTIONS...]  COMMAND  [LINK...]</p></div></div><div class="refsect1"><a name="id-1.5"></a><h2 id="描述">描述<a class="headerlink" title="Permalink to this headline" href="networkctl.html#%E6%8F%8F%E8%BF%B0">¶</a></h2><p><span class="command"><strong>networkctl</strong></span>
    用于查询
    <span class="command"><strong>systemd-networkd</strong></span> 所看到的网络连接的状态。参见
    <a href="systemd-networkd.service.html#"><span class="citerefentry"><span class="refentrytitle">systemd-networkd.service</span>(8)</span></a>
    以了解
    相关概念、功能、配置语法。</p></div><div class="refsect1"><a name="id-1.6"></a><h2 id="选项">选项<a class="headerlink" title="Permalink to this headline" href="networkctl.html#%E9%80%89%E9%A1%B9">¶</a></h2><p>能够识别的命令行选项如下：</p><div class="variablelist"><dl class="variablelist"><dt id="
          -a
          --all
        "><span class="term">
          <code class="option">-a</code>
          <code class="option">--all</code>
        </span><a class="headerlink" title="Permalink to this term" href="networkctl.html#%0A%20%20%20%20%20%20%20%20%20%20-a%0A%20%20%20%20%20%20%20%20%20%20--all%0A%20%20%20%20%20%20%20%20">¶</a></dt><dd><p>显示所有连接的状态(<span class="command"><strong>status</strong></span>)</p></dd><dt id="-h"><span class="term"><code class="option">-h</code>, </span><span class="term"><code class="option">--help</code></span><a class="headerlink" title="Permalink to this term" href="networkctl.html#-h">¶</a></dt><dd><p><a name="help-text"></a>显示简短的帮助信息并退出。
    </p></dd><dt id="--version"><span class="term"><code class="option">--version</code></span><a class="headerlink" title="Permalink to this term" href="networkctl.html#--version">¶</a></dt><dd><p><a name="version-text"></a>显示简短的版本信息并退出。</p></dd><dt id="--no-legend"><span class="term"><code class="option">--no-legend</code></span><a class="headerlink" title="Permalink to this term" href="networkctl.html#--no-legend">¶</a></dt><dd><p>不输出列标题，
      也就是不在输出列表的头部和尾部显示字段的名称。</p></dd><dt id="--no-pager"><span class="term"><code class="option">--no-pager</code></span><a class="headerlink" title="Permalink to this term" href="networkctl.html#--no-pager">¶</a></dt><dd><p>不将程序的输出内容管道(pipe)给分页程序。</p></dd></dl></div></div><div class="refsect1"><a name="id-1.7"></a><h2 id="命令">命令<a class="headerlink" title="Permalink to this headline" href="networkctl.html#%E5%91%BD%E4%BB%A4">¶</a></h2><p>能够识别的命令如下：</p><div class="variablelist"><dl class="variablelist"><dt id="
          list
          LINK…
        "><span class="term">
          <span class="command"><strong>list</strong></span>
          [<span class="optional"><em class="replaceable"><code>LINK…</code></em></span>]
        </span><a class="headerlink" title="Permalink to this term" href="networkctl.html#%0A%20%20%20%20%20%20%20%20%20%20list%0A%20%20%20%20%20%20%20%20%20%20LINK%E2%80%A6%0A%20%20%20%20%20%20%20%20">¶</a></dt><dd><p>列出存在的连接及其状态。若未指定连接(LINK)则显示所有连接，
          否则仅显示指定的连接。一个典型的输出类似下面这样：

          </p><pre class="programlisting">IDX LINK         TYPE     OPERATIONAL SETUP
  1 lo           loopback carrier     unmanaged
  2 eth0         ether    routable    configured
  3 virbr0       ether    no-carrier  unmanaged
  4 virbr0-nic   ether    off         unmanaged

4 links listed.</pre><p>OPERATIONAL(操作)状态可以是如下之一：
            </p><div class="variablelist"><dl class="variablelist"><dt id="off"><span class="term">off</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#off">¶</a></dt><dd><p>该设备已被断电关闭</p></dd><dt id="no-carrier"><span class="term">no-carrier</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#no-carrier">¶</a></dt><dd><p>设备已通电开启，但是尚无网络载波(光电信号)</p></dd><dt id="dormant"><span class="term">dormant</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#dormant">¶</a></dt><dd><p>设备上已有网络载波(光电信号)，但是尚未准备好进行网络传输(收发数据包)</p></dd><dt id="carrier"><span class="term">carrier</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#carrier">¶</a></dt><dd><p>连接已具备收发数据包的能力</p></dd><dt id="degraded"><span class="term">degraded</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#degraded">¶</a></dt><dd><p>连接已具备收发数据包的能力，并且已经配置了有效地址</p></dd><dt id="routable"><span class="term">routable</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#routable">¶</a></dt><dd><p>连接已具备收发数据包的能力，并且已经配置了可路由地址</p></dd></dl></div><p>
        </p><p>SETUP(安装)状态可以是如下之一：
            </p><div class="variablelist"><dl class="variablelist"><dt id="pending"><span class="term">pending</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#pending">¶</a></dt><dd><p>udev 正在处理此连接，目前尚不确定是否可以管理此连接。</p></dd><dt id="failed"><span class="term">failed</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#failed">¶</a></dt><dd><p>networkd 管理此连接失败</p></dd><dt id="configuring"><span class="term">configuring</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#configuring">¶</a></dt><dd><p>正在配置此连接的过程中</p></dd><dt id="configured"><span class="term">configured</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#configured">¶</a></dt><dd><p>连接已被配置成功</p></dd><dt id="unmanaged"><span class="term">unmanaged</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#unmanaged">¶</a></dt><dd><p>此连接不受 networkd 管理(可能由发行版专用的方式管理)</p></dd><dt id="linger"><span class="term">linger</span><a class="headerlink" title="Permalink to this term" href="networkctl.html#linger">¶</a></dt><dd><p>连接已经不存在，但是(配置信息)尚未被 networkd 丢弃。</p></dd></dl></div><p>
        </p></dd><dt id="
          status
          LINK…
        "><span class="term">
          <span class="command"><strong>status</strong></span>
          [<span class="optional"><em class="replaceable"><code>LINK…</code></em></span>]
        </span><a class="headerlink" title="Permalink to this term" href="networkctl.html#%0A%20%20%20%20%20%20%20%20%20%20status%0A%20%20%20%20%20%20%20%20%20%20LINK%E2%80%A6%0A%20%20%20%20%20%20%20%20">¶</a></dt><dd><p>显示连接的各种信息：
          类型、状态、内核模块、MAC地址、IP地址、DNS服务器，
          等等。</p><p>若未指定连接(LINK)则显示网络状态概览，否则仅显示指定连接的详细信息。参见
          <code class="option">--all</code> 选项。</p><p>一个典型的输出类似下面这样：
          </p><pre class="programlisting">
●      State: routable
     Address: 10.193.76.5 on eth0
              192.168.122.1 on virbr0
              169.254.190.105 on eth0
              fe80::5054:aa:bbbb:cccc on eth0
     Gateway: 10.193.11.1 (CISCO SYSTEMS, INC.) on eth0
         DNS: 8.8.8.8
              8.8.4.4</pre></dd><dt id="
          lldp
          LINK…
        "><span class="term">
          <span class="command"><strong>lldp</strong></span>
          [<span class="optional"><em class="replaceable"><code>LINK…</code></em></span>]
        </span><a class="headerlink" title="Permalink to this term" href="networkctl.html#%0A%20%20%20%20%20%20%20%20%20%20lldp%0A%20%20%20%20%20%20%20%20%20%20LINK%E2%80%A6%0A%20%20%20%20%20%20%20%20">¶</a></dt><dd><p>显示已发现的 LLDP (Link Layer Discovery Protocol) 邻居。
          若未指定连接(LINK)则显示所有连接上发现的邻居，否则仅显示指定连接上发现的邻居。
          注意，此命令仅在指定的连接(LINK)已经启用了 <code class="varname">LLDP=</code> 特性的情况下才有意义。参见
          <a href="systemd.network.html#"><span class="citerefentry"><span class="refentrytitle">systemd.network</span>(5)</span></a>
          以了解详情。</p><p>一个典型的输出类似下面这样：
          </p><pre class="programlisting">LINK             CHASSIS ID        SYSTEM NAME      CAPS        PORT ID           PORT DESCRIPTION
enp0s25          00:e0:4c:00:00:00 GS1900           ..b........ 2                 Port #2

Capability Flags:
o - Other; p - Repeater;  b - Bridge; w - WLAN Access Point; r - Router;
t - Telephone; d - DOCSIS cable device; a - Station; c - Customer VLAN;
s - Service VLAN, m - Two-port MAC Relay (TPMR)

1 neighbors listed.</pre></dd><dt id="
          label
        "><span class="term">
          <span class="command"><strong>label</strong></span>
        </span><a class="headerlink" title="Permalink to this term" href="networkctl.html#%0A%20%20%20%20%20%20%20%20%20%20label%0A%20%20%20%20%20%20%20%20">¶</a></dt><dd><p>显示以数字形式表示的地址标签，可用于地址选择。
        该命令显示的内容与
        <a href="http://www.jinbuguo.com/systemd/ip-addrlabel.html#"><span class="citerefentry"><span class="refentrytitle">ip-addrlabel</span>(8)</span></a>
        相同。详见 <a class="ulink" href="https://tools.ietf.org/html/rfc3484" target="_top">RFC 3484</a>
        以了解更多与"地址标签"相关的讨论。</p><p>一个典型的输出类似下面这样：
        </p><pre class="programlisting">Prefix/Prefixlen                          Label
        ::/0                                  1
    fc00::/7                                  5
    fec0::/10                                11
    2002::/16                                 2
    3ffe::/16                                12
 2001:10::/28                                 7
    2001::/32                                 6
::ffff:0.0.0.0/96                             4
        ::/96                                 3
       ::1/128                                0</pre></dd></dl></div></div><div class="refsect1"><a name="id-1.8"></a><h2 id="退出状态">退出状态<a class="headerlink" title="Permalink to this headline" href="networkctl.html#%E9%80%80%E5%87%BA%E7%8A%B6%E6%80%81">¶</a></h2><p>返回值为 0 表示成功，非零返回值表示失败代码。</p></div><div class="refsect1"><a name="id-1.9"></a><h2 id="参见">参见<a class="headerlink" title="Permalink to this headline" href="networkctl.html#%E5%8F%82%E8%A7%81">¶</a></h2><p>
      <a href="systemd-networkd.service.html#"><span class="citerefentry"><span class="refentrytitle">systemd-networkd.service</span>(8)</span></a>,
      <a href="systemd.network.html#"><span class="citerefentry"><span class="refentrytitle">systemd.network</span>(5)</span></a>,
      <a href="systemd.netdev.html#"><span class="citerefentry"><span class="refentrytitle">systemd.netdev</span>(5)</span></a>,
      <a href="https://linux.die.net/man/8/ip"><span class="citerefentry"><span class="refentrytitle">ip</span>(8)</span></a>
    </p></div></div></body></html>
